home *** CD-ROM | disk | FTP | other *** search
- /*
- File: IconUtilCheck.c
-
- Contains: According to the Tech Note OV - 16, "Inside Macintosh: More Macintosh
- Toolbox, page 5-7, specifies that the gestaltIconUtilitiesAttr - 'icon'
- gestalt selector can be used to determine whether the icon utilities
- are present under System 7.x. Note that this selector is included in
- the GestaltEqu files. It turns out that this selector is not
- implemented until System Software v7.1.2. To check for the existence of
- these utilities, use the TrapAvailable code to check for the
- _IconDispatch, (0xABC9) trap. The TrapAvailable code is presented in
- Inside Macintosh VI 3-8, and as sample code in many of the snippets
- on the Developer CD."
-
- This snippet shows how to determine whether the Icon Utilities
- are available.
-
- Written by: Virginia (Ginny) McCulloh
-
- Copyright: Copyright © 1995-1999 by Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- 8/6/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1
-
-
- */
-
- #include <stdio.h>
- #include <Types.h>
- #include <OSUtils.h>
- #include <GestaltEqu.h>
-
- #ifndef __TRAPS__
- #include <Traps.h>
- #endif
-
- #define TrapMask 0x0800
-
-
- Boolean TrapAvailable(short theTrap);
- short NumToolboxTraps(void);
- TrapType GetTrapType(short theTrap);
-
- short NumToolboxTraps(void)
- {
- if (NGetTrapAddress(_InitGraf, ToolTrap) == NGetTrapAddress(0xAA6E,ToolTrap))
- return 0x0200;
- else
- return 0x0400;
- }
-
- TrapType GetTrapType(short theTrap)
- {
- if ((theTrap & TrapMask) > 0)
- return ToolTrap;
- else
- return OSTrap;
- }
-
- Boolean TrapAvailable(short theTrap)
- {
- TrapType tType;
- Boolean isAvail;
-
- tType = GetTrapType(theTrap);
- if (tType == ToolTrap)
- {
- theTrap &= 0x07FF;
- if (theTrap >= NumToolboxTraps())
- theTrap = _Unimplemented;
- }
-
- isAvail = NGetTrapAddress(theTrap, tType) != NGetTrapAddress(_Unimplemented, ToolTrap);
- return isAvail;
- }
-
- void main(void)
- {
- printf("Testing for presence of Icon Utilities\n");
- if (TrapAvailable(_IconDispatch))
- printf("Icon Utilities are available\n");
- else
- printf("Icon Utilities are not available\n");
- }
-